﻿using System;
using System.Collections.Generic;
using System.Linq;
using Mbs.Elements;
using NUnit.Framework;

namespace Mbs.Test.ElementBuilder
{
    [TestFixture]
    public class ElementBuilderRepositoryTest:TestBase
    {
        [Test]
        public void Test()
        {


            foreach (var key in elementKeys)
            {
                var item = ServiceLocator.Current.Get<IElementBuilder>(key);
                if (item == null)
                    Console.WriteLine(key);
                //Assert.IsNotNull(ServiceLocator.Current.Get<IElementBuilder>(key));
            }

            List<item> list = new List<item>();
            list.Add(new item() { Name = "x", Comein = 12.0f });
            list.Add(new item() { Name = "b", Comein = 12.0f });
            list.Add(new item() { Name = "d", Comein = 12.0f });
            list.Add(new item() { Name = "x", Comein = 12.0f });
            list.Add(new item() { Name = "e", Comein = 12.0f });
            list.Add(new item() { Name = "b", Comein = 12.0f });

            var result = (from it in list
                          group it by it.Name into g
                          select new { Name = g.Key, Sum = g.Sum(iit => iit.Comein) }).ToList();
            //foreach (var item in result)
            //    Console.WriteLine(item.ToString() + "  " + item.Sum.ToString());

       
        }

        
        class item
        {
            public string Name { get; set; }
            public double Comein { get; set; }
        }
    }
}
